package aptech.eproject.logictics.db;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;

/**
 * The persistent class for the TRIP database table.
 * 
 */
@Entity
@Table(name = "TRIP")
public class Trip implements Serializable {

    private static final long serialVersionUID = 1L;
    private int tripId;
    private Timestamp arriveDate;
    private boolean isDeleted;
    private boolean isFinished;
    private short maxRoute;
    private Timestamp startDate;
    private Vehicle vehicle;
    private Set<TripPackage> tripPackages;
    private Set<TripRoute> tripRoutes;

    public Trip() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "TRIP_ID")
    public int getTripId() {
        return this.tripId;
    }

    public void setTripId(int tripId) {
        this.tripId = tripId;
    }

    @Column(name = "ARRIVE_DATE", nullable = true)
    public Timestamp getArriveDate() {
        return this.arriveDate;
    }

    public void setArriveDate(Timestamp arriveDate) {
        this.arriveDate = arriveDate;
    }

    @Column(name = "IS_DELETED", nullable = true)
    public boolean getIsDeleted() {
        return this.isDeleted;
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Column(name = "IS_FINISHED", nullable = true)
    public boolean getIsFinished() {
        return this.isFinished;
    }

    public void setIsFinished(boolean isFinished) {
        this.isFinished = isFinished;
    }

    @Column(name = "MAX_ROUTE", nullable = true)
    public short getMaxRoute() {
        return this.maxRoute;
    }

    public void setMaxRoute(short maxRoute) {
        this.maxRoute = maxRoute;
    }

    @Column(name = "START_DATE", nullable = false)
    public Timestamp getStartDate() {
        return this.startDate;
    }

    public void setStartDate(Timestamp startDate) {
        this.startDate = startDate;

    }

    //bi-directional many-to-one association to Vehicle
    @ManyToOne
    @JoinColumn(name = "VEHICLE_ID", nullable = false)
    public Vehicle getVehicle() {
        return this.vehicle;
    }

    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

    //bi-directional many-to-one association to TripPackage
    @OneToMany(mappedBy = "trip", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    public Set<TripPackage> getTripPackages() {
        return this.tripPackages;
    }

    public void setTripPackages(Set<TripPackage> tripPackages) {
        this.tripPackages = tripPackages;
    }

    public TripPackage addTripPackage(TripPackage tripPackage) {
        getTripPackages().add(tripPackage);
        return tripPackage;
    }

    public TripPackage removeTripPackage(TripPackage tripPackage) {
        getTripPackages().remove(tripPackage);
        tripPackage.setTrip(null);
        return tripPackage;
    }

    //bi-directional many-to-one association to TripRoute
    @OneToMany(mappedBy = "trip", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    public Set<TripRoute> getTripRoutes() {
        return this.tripRoutes;
    }

    public void setTripRoutes(Set<TripRoute> tripRoutes) {
        this.tripRoutes = tripRoutes;
    }

    public TripRoute addTripRoute(TripRoute tripRoute) {
        getTripRoutes().add(tripRoute);
        return tripRoute;
    }

    public TripRoute removeTripRoute(TripRoute tripRoute) {
        getTripRoutes().remove(tripRoute);
        tripRoute.setTrip(null);
        return tripRoute;
    }
}
